{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "(How_to_Use_This_Book)=\n",
    "# How to use this book\n",
    "\n",
    "\n",
    "This book is a [Jupyter Book](https://jupyterbook.org/intro.html), which allows you to interactively execute, reproduce, or modify the sections of this book that contain code. This chapter provides an overview of what Jupyter books are, and how they allow their content to be reproducible. \n",
    "\n",
    "\n",
    "## Jupyter book project\n",
    "\n",
    "The Jupyter Book project is an open-source project. It is developed by the [Executable Book Project](https://executablebooks.org/en/latest/), which is an [international collaboration between several universities and other open-source projects](https://executablebooks.org/en/latest/about.html). \n",
    "\n",
    "Under the hood, a Jupyter Book is essentially a collection of markdown files and Jupyter notebooks. These files are compiled together according to the configuration and table of content specifications. You can follow the Github icon at the top of this page to see the source code for this book. \n",
    "\n",
    "\n",
    "## Book layout\n",
    "\n",
    "The book layout provides five main zones:\n",
    "\n",
    "1. The search tool (top left): It allows finding all sections of the book that contains a particular term.\n",
    "2. The table of content (left panel): It allows navigating between the different chapters and main sections of the book.\n",
    "3. The external links (top): It contains icons for launching notebooks, switching to full-screen mode, accessing the Github repository, or downloading the content of the current section.\n",
    "4. The main panel (center): The content of the current section.\n",
    "5. The section content (Right panel): It allows navigating in the subsections of the current section. \n",
    "\n",
    "\n",
    "\n",
    "\n",
    "## Reproducibility\n",
    "\n",
    "All sections that contain code (Jupyter notebooks), such as this section, will have a shuttle icon in the external links, allowing to run the notebook on the cloud. Two services are provided: Google Colab, and Binder. We briefly describe these two services below, with their pros and cons. \n",
    "\n",
    "### Google Colab\n",
    "\n",
    "\n",
    "[Google Colab](https://colab.research.google.com/notebooks/intro.ipynb#) is a service provided by Google Research and requires to have a Google account. It allows to run Python notebooks for free on Google cloud. \n",
    "\n",
    "The computational resources provided by Google Colab can fluctuate. They depend on available Google resources, as well as your usage of the service (intense use may lead to lower resources). You may however expect to have one core, and a few gigabytes of RAM. Google Colab also provides a free GPU, whose model may vary depending on available resources. Provided GPU models often include Nvidia K80s, T4s, P4s, or P100s. See this [link](https://research.google.com/colaboratory/faq.html?hl=ko-KRUbuntu) for more details on the resources that Google can provide. \n",
    "\n",
    "### Binder\n",
    "\n",
    "[Binder](https://mybinder.readthedocs.io/en/latest/index.html) {cite}`beg2021using` allows to create, use and share custom computing environments. It is powered by [BinderHub](https://github.com/jupyterhub/binderhub), which is an open-source tool that deploys the Binder service in the cloud. \n",
    "\n",
    "Notebooks may be launched and run for free, thanks to the [BinderHub Federation](https://mybinder.readthedocs.io/en/latest/about/federation.html), currently supported by Google Cloud Platform, OVH, GESIS notebooks, and the Alan Turing Institute. BinderHub relies on [Repo2Docker](https://github.com/jupyterhub/repo2docker) to generate docker images from a Git repository, and [JupyterHub](https://github.com/jupyterhub/jupyterhub) to run and share notebooks. \n",
    "\n",
    "It takes usually around one or two minutes for Binder to create a Docker container and start serving a notebook. The `environment.yml` file, present at the root of the Github book repository, is used to specify which Python libraries must be installed in the docker container. \n",
    "\n",
    "As with Google Colab, the resources provided for free by the BinderHub Federation fluctuate. See the [Binder user guide](https://mybinder.readthedocs.io/en/latest/about/about.html) and [Binder user guidelines](https://mybinder.readthedocs.io/en/latest/about/user-guidelines.html) for more details on the resources that the BinderHub Federation can provide. \n",
    "\n",
    "\n",
    "### Pros and cons\n",
    "\n",
    "A summary of the features of Google Colab and Binder is provided below. \n",
    "\n",
    "\n",
    "|| Google Colab | Binder|\n",
    ":----- | :---- | :-----\n",
    "|Registration   | Requires a Google login | None|\n",
    "|CPU resources | Fluctuate  | Fluctuate|\n",
    "|RAM resources | Fluctuate  | Fluctuate|\n",
    "|GPU resources | Fluctuate. Often includes Nvidia K80s, T4s, P4s, or P100s  | None|\n",
    "|Session duration  | Up to 12 hours  | Up to 12 hours|\n",
    "|Environment  | Python 3.6 | Customizable with environment.yml file|\n",
    "\n",
    "In our experience, Google Colab execution times are about twice as fast as Binder. \n",
    "\n",
    "This summary reflects the status of the two services at the time of the writing of this section (January 2021). The features of these two services are however expected to evolve in the short future.  \n",
    "\n",
    "\n",
    "\n",
    "### Try it!\n",
    "\n",
    "Open this notebook using either Google Colab or Binder to execute the following cell:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello world!\n"
     ]
    }
   ],
   "source": [
    "print('Hello world!')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Local execution and book compilation\n",
    "\n",
    "This is an open-source book, and the code is made [available on GitHub](https://github.com/Fraud-Detection-Handbook/fraud-detection-handbook) (or by following the GitHub icon in the external links at the top of this page). You may run the book notebooks on your computer by cloning the GitHub repository. \n",
    "\n",
    "You may also recompile the book. Compiling the book will first require you to [install Jupyter Book](https://jupyterbook.org/intro.html#install-jupyter-book).\n",
    "\n",
    "Once done, this is a two-step process:\n",
    "\n",
    "1. Clone the book repository:\n",
    "\n",
    "```\n",
    "git clone https://github.com/Fraud-Detection-Handbook/fraud-detection-handbook\n",
    "```\n",
    "\n",
    "2. Compile the book\n",
    "\n",
    "```\n",
    "jupyter-book build fraud-detection-handbook\n",
    "```\n",
    "\n",
    "The book will be available locally at `fraud-detection-handbook/_build/html/index.html`.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
